﻿using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using Kinect = Windows.Kinect;

public class GestureExpand : GestureBase
{
    private static float GestureTwoHandDistance(Kinect.Body body)
    {
        if (body == null)
            return 0;

        Kinect.Joint leftJoint = body.Joints[Kinect.JointType.WristLeft];
        Kinect.Joint rightJoint = body.Joints[Kinect.JointType.WristRight];
        Vector3 vLeft = GestureHelper.GetVector3FromJoint(leftJoint);
        Vector3 vRight = GestureHelper.GetVector3FromJoint(rightJoint);

        float dis = Vector3.Distance(vLeft, vRight);

        return dis;
    }

    public override bool IsInGesture(Kinect.Body body)
    {
        if (body == null)
            return false;
        Vector3 vLeftWirstToSpineMid = GestureHelper.GetVector3FromJoints(body.Joints[Kinect.JointType.WristLeft], body.Joints[Kinect.JointType.SpineMid]);
        Vector3 vRightWirstToSpineMid = GestureHelper.GetVector3FromJoints(body.Joints[Kinect.JointType.WristRight], body.Joints[Kinect.JointType.SpineMid]);

        if (vLeftWirstToSpineMid.y > 0 || vRightWirstToSpineMid.y > 0)
            return false;
        return true;
    }
    public override float GetValue(Kinect.Body body)
    {
        float value = GestureTwoHandDistance(body);
        value = Mathf.Clamp(value,fMinValue,fMaxValue);
        return value;
    }
    public override void OnTrace(Kinect.Body body)
    {

    }

    public override void OnNoTrace(Kinect.Body body)
    {

    }
    public override void Destroy()
    {

    }
}
